<%@page import="com.mavenrentcars.model.Car"%>
<%@page import="java.util.List"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/header.jsp" %>

<% 
	List<Car> list = (List<Car>) request.getAttribute("list");
%>

        <h1>Cars List</h1> 
        <div><a href="car_item.htm" >Add </a></div><br>
        <% if(list != null) { %>
		<div id="cars_list">
            
            <table>
                <thead>
                    <tr>
                        <th>Model</th>
                        <th>Output Year</th>
                        <th>Insurance</th>
                        <th>Price</th>
                        <th>Start Place</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <%
                    for(Car item : list) {
                    %>
                    <tr>
                        <td><%=item.getModel() %></td>
                        <td><%=item.getOutputYear() %></td>
                        <td><%=item.getInsurance() %></td>
                        <td><%=item.getPrice() %></td>
                        <td><%=item.getStartPlace().getPlaceName() %></td>
                        <td>
                            <a href="car_item.htm?id=<%=item.getId() %>" >View </a> | 
                            <a href="car_orders_list.htm?id=<%=item.getId() %>" >Orders </a> | 
                            <a href="car_delete.htm?id=<%=item.getId() %>" >Delete </a>
                        </td>
                    </tr>
                    <% } %>
                                
                </tbody>
            </table>

        </div>
        <% } %>
		
    
<%@ include file="/WEB-INF/jsp/footer.jsp" %>